<template>
	<view :style="objColor">
		<!-- pages/site/index.wxml -->
		<!-- 搜索框 -->
		<view class="search" :animation="toolAnimation">
			<view class="search_box screen">
				<!-- <view class="location" @click="goLocation">
					<view class="city_name">{{ cityname || '请选择' }}</view>
					<image class="icon" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/down.png"></image>
				</view> -->
				<view class="search_input">
					<!-- 搜索框 -->
					<view class="weui-search-bar">
						<view class="weui-search-bar__form">
							<!-- 点击之后，跳转搜索页面 -->
							<view class="weui-search-bar__box">
								<icon class="weui-icon-search_in-box" type="search" size="16"></icon>
								<input type="text" class="weui-search-bar__input" placeholder="输入站点名称/桩号搜索"
									@tap="goSearch" />
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="notice_box" @tap="goNotice">
					<image class="img" :src="(mixOtherIconList[2] && mixOtherIconList[2].icon) || 'https://oos-cn.ctyunapi.cn/front-end/static/static/information.png'"></image>
					<text class="tipInfo" v-if="readStatus"></text>
				</view> -->

				<view class="preference" @tap="showPreferenceFun">
					<text>筛选</text>
					<image class="preferenceImg" src="https://oos-cn.ctyunapi.cn/front-end/static/static/screening.png"
						mode="widthFix"></image>
				</view>
			</view>


			<view class="siteLabel_selection" style="margin-top: 16px;">
				<siteLabelSelection ref="siteLabelSelectionRef" @backHome="gaode()"></siteLabelSelection>
			</view>



			<!-- <view class="screen">
				<view class="preference" @tap="showPreferenceFun">
					<text>筛选</text>
					<image class="preferenceImg" src="https://oos-cn.ctyunapi.cn/front-end/static/static/screening.png"
								 mode="widthFix"></image>
				</view>
				<view class="siteList" @tap="goSiteList" v-if="isToken">
					<image class="siteListImg" src="https://oos-cn.ctyunapi.cn/front-end/static/static/more.png"
								 mode="widthFix"></image>
					列表
				</view>
			</view> -->

		</view>
		<!-- 地图 -->
		<view class="map_container" v-if="!showRegion && !showPreference">
			<!-- #ifdef MP-WEIXIN || MP-ALIPAY-->
			<map class="map" id="map" :longitude="longitude" :latitude="latitude" scale="14"
				:show-location="showLocation" @markertap="markertap" @updated="mapUpdated"></map>
			<!-- #endif -->
			<!-- #ifdef H5 -->
			<view class="map" id="map"></view>
			<!-- #endif -->
		</view>

		<!-- 滚动通告 -->
		<view class="message" v-if="message">
			<image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/static/new2.png"></image>
			<swiper class="message-swiper" :circular="true" :vertical="true" :autoplay="true" interval="3000"
				duration="1000">
				<swiper-item v-for="(item, index) in noticeList" :key="index">
					<view class="text" @tap="noticeDetails" :data-item="item">
						{{ item.name }}
					</view>
				</swiper-item>
			</swiper>
		</view>
		<!-- 当前位置 -->
		<!-- <view class="imageArr">
			<view @tap="centralPoint">
				<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/map_ldq.png"></image>
			</view>
		</view> -->

		<view class="imageArrs">
			<view class="point_view" @tap="centralPoint">
				<image class="icons" src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/icon-dinwei.png">
				</image>
				<view class="text">
					定位
				</view>
			</view>

			<view class="point_view" style="margin-top: 24rpx;" @tap="goCode" v-if="isToken">
				<image class="icons2" src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/icon-qiangbianhao.png">
				</image>
				<view class="text">
					枪编号
				</view>
			</view>
		</view>

		<!-- 桩号充电 -->
		<!-- <view @tap="goCode" class="stationCharging" v-if="isToken">
			<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/charging_pile_no.png" mode="widthFix"></image>
		</view> -->
		<!-- 超、快、慢充筛选 -->
		<!-- <view class="chargingType" v-if="isToken">
			<view class="tagging0" @tap="checkChargingType1">
				<image class="img" src="https://oos-cn.ctyunapi.cn/front-end/static/static/tagging0.png"></image>
				<view class="txt0">全部</view>
				<image v-if="chargingIndex == -1" class="checktype"
							 src="https://oos-cn.ctyunapi.cn/front-end/static/static/fill.png"></image>
			</view>
			<view class="chargingTypeBox">
				<template v-if="site_pattern === 'SUPER_FAST_SLOW_PATTERN'">
					<view class="chargingTypeItem" :data-index="index" :data-key="item.key" data-type="rate"
								@tap="checkChargingType" v-for="(item, index) in chargingTypeList" :key="index">
						<image class="img" :src="item.img" mode="aspectFill"></image>
						<view class="txt">{{ item.name }}</view>
						<image v-if="chargingIndex == index" class="checktype"
									 src="https://oos-cn.ctyunapi.cn/front-end/static/static/fill.png"></image>
					</view>
				</template>
				<template v-if="site_pattern === 'IS_ACTIVITY_PATTERN'">
					<view class="chargingTypeItem" :data-index="index" :data-key="item.key" data-type="activity"
								@tap="checkChargingType" v-for="(item, index) in chargingTypeList2" :key="index">
						<image class="img" :src="item.img" mode="aspectFill"></image>
						<view class="txt">{{ item.name }}</view>
						<image v-if="chargingIndex == index" class="checktype"
									 src="https://oos-cn.ctyunapi.cn/front-end/static/static/fill.png"></image>
					</view>
				</template>
			</view>
		</view> -->
		<!-- 地区 -->
		<u-popup :show="showRegion" mode="top" @close="onCloseRegion">
			<view class="search" :animation="toolAnimation">
				<view class="search_box">
					<view class="location" @click="goLocation">
						<view class="city_name">{{ cityname || '请选择' }}</view>
						<image class="icon" src="https://oos-cn.ctyunapi.cn/front-end/static/homeSub/images/down.png">
						</image>
					</view>
					<view class="search_input">
						<!-- 搜索框 -->
						<view class="weui-search-bar">
							<view class="weui-search-bar__form">
								<!-- 点击之后，跳转搜索页面 -->
								<view class="weui-search-bar__box">
									<icon class="weui-icon-search_in-box" type="search" size="16"></icon>
									<input type="text" class="weui-search-bar__input" placeholder="输入站点名称/桩号搜索" @tap="goSearch" />
								</view>
							</view>
						</view>
					</view>
					<view class="notice_box" @tap="goNotice">
						<image class="img"
							:src="(mixOtherIconList[2] && mixOtherIconList[2].icon) || 'https://oos-cn.ctyunapi.cn/front-end/static/static/information.png'">
						</image>
						<text class="tipInfo" v-if="readStatus"></text>
					</view>
				</view>
				<view class="screen">
					<!-- <view class="region" @tap="showRegionFun">
							地区
							<image class="regionImg" src="https://oos-cn.ctyunapi.cn/front-end/static/static/down.png"></image>
					</view> -->
					<view class="preference" @tap="showPreferenceFun">
						<text>筛选</text>
						<image class="preferenceImg"
							src="https://oos-cn.ctyunapi.cn/front-end/static/static/screening.png" mode="widthFix">
						</image>
					</view>
					<view class="siteList" @tap="goSiteList">
						<image class="siteListImg" src="https://oos-cn.ctyunapi.cn/front-end/static/static/more.png"
							mode="widthFix"></image>
						列表
					</view>
				</view>
			</view>
			<view class="pop_top1">
				<view class="content_list_Region">
					<scroll-view scroll-y="true" class="scroll_view_style">
						<view class="area">
							<view :class="item.isCheck ? 'areaItem_sel' : 'areaItem'" @tap="checkArea"
								:data-id="item.id" v-for="(item, index) in regionList" :key="index">
								{{ item.name }}
							</view>
						</view>
					</scroll-view>
				</view>
				<view class="type_btn">
					<view class="btn1" @tap="canalRegion">清除</view>
					<view class="btn2" @tap="enterRegion" :style="'background:'+ objColor2.textColor">确定</view>
				</view>
			</view>
		</u-popup>
		<!-- 偏好 -->
		<u-popup :show="showPreference" mode="bottom" custom-style="height:80%;" @close="onClosePreference">
			<view class="pop_title">筛选</view>
			<view class="pop_top">
				<view class="content_list">
					<scroll-view scroll-y="true" class="scroll_view_style">
						<!-- 距离 -->
						<view class="type">
							<view class="type_title">{{ distanceList.name }}</view>
							<view class="type_list">
								<view
									:class="memberQueryPreferenceDto.distance == item.key ? 'type_itme_sel' : 'type_itme'"
									@tap="checkDistance" :data-key="item.key" v-for="(item, index) in distanceList.list"
									:key="index">
									{{ item.value }}
								</view>
							</view>
						</view>
						<!-- 站点类型 -->
						<view class="type">
							<view class="type_title">{{ siteTypeList.name }}</view>
							<view class="type_list">
								<view
									:class="memberQueryPreferenceDto.stationType == item.key ? 'type_itme_sel' : 'type_itme'"
									@tap="checkSiteType" :data-key="item.key" v-for="(item, index) in siteTypeList.list"
									:key="index">
									{{ item.value }}
								</view>
							</view>
						</view>
						<!-- 充电模式 -->
						<view class="type">
							<view class="type_title">{{ chargingModeList.name }}</view>
							<view class="type_list">
								<view
									:class="memberQueryPreferenceDto.fastSlow == item.key ? 'type_itme_sel' : 'type_itme'"
									@tap="checkChargingMode" :data-key="item.key"
									v-for="(item, index) in chargingModeList.list" :key="index">
									{{ item.value }}
								</view>
							</view>
						</view>
						<!-- 建设场所 -->
						<view class="type">
							<view class="type_title">{{ constructionSiteList.name }}</view>
							<view class="type_list">
								<view
									:class="memberQueryPreferenceDto.construction == item.key ? 'type_itme_sel' : 'type_itme'"
									@tap="checkConstructionSite" :data-key="item.key"
									v-for="(item, index) in constructionSiteList.list" :key="index">
									{{ item.value }}
								</view>
							</view>
						</view>
						<!-- 优惠 -->
						<!-- <view class="type">
								<view class="type_title">{{ discountList.name }}</view>
								<view class="type_list">
										<view
												:class="memberQueryPreferenceDto.discount == item.key ? 'type_itme_sel' : 'type_itme'"
												@tap="checkIsDiscount"
												:data-key="item.key"
												v-for="(item, index) in discountList.list"
												:key="index"
										>
												{{ item.value }}
										</view>
								</view>
						</view> -->
					</scroll-view>
				</view>
				<view class="type_btn">
					<view class="btn1" @tap="canalPreference">清除</view>
					<view class="btn2" @tap="enterPreference" :style="'background:'+ objColor2.textColor">确定</view>
				</view>
			</view>
		</u-popup>


		<view class="detail_popups" v-if="showSiteDetail">
			<view class="close_view">
				<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/delete.png" @tap="closeSiteModal">
				</image>
			</view>

			<view class="order order_site_view">
				<view @tap="handleToDetails(siteItemData)" :data-id="siteItemData.id">
					<view class="top">
						<view class="top_name">
							{{ siteItemData.name }}
						</view>
						<view class="right ok" @tap.stop.prevent="goAddress" :data-latitude="siteItemData.latitude"
							:data-longitude="siteItemData.longitude" :data-name="siteItemData.street" :data-street="siteItemData.street">
							<text>{{ siteItemData.distance }} km</text>
							<image
								:src="(mixOtherIconList[0] && mixOtherIconList[0].icon) || 'https://oos-cn.ctyunapi.cn/front-end/static/static/Navigation.png'"
								mode="aspectFill"></image>
						</view>
					</view>
					<!-- <view class="tagList" v-if="siteItemData.tagList && siteItemData.tagList.length > 0">
						<view
										class="p"
										:class="[t.bright == 1? 'tag1' : 'tag2']"
										v-if="t.tagName"
										v-for="(t, index1) in siteItemData.tagList"
										:key="index1">
							<text>{{ t.tagName }}</text>
						</view>
					</view> -->

					<!-- 831标签修改样式 -->
					<view class="tagList_view"
						v-if="siteItemData.tagList && siteItemData.tagList.length > 0 || siteItemData.featured==1">
						<view class="tag_yxbq" v-if="siteItemData.featured==1">
							<image class="v_icon"
								src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/icon-youxuan.png"
								mode="scaleToFill" />
							<text class="v_text">
								优选
							</text>
						</view>
						<view :class="[t.bright == 1? 'tag_item tag_gaoliang' : 'tag_item']"
							v-for="(t, index1) in siteItemData.tagList" :key="index1">
							<text>{{ t.tagName}}</text>
						</view>
					</view>


					<!-- <view class="price-info">
						<view v-if="siteItemData.discount || siteItemData.contractDiscount" class="price">
							<image class="active-icon" src="https://oos-cn.ctyunapi.cn/front-end/static/static/car.png"
											mode="heightFix" v-if="siteItemData.contractDiscount"></image>
							<image class="active-icon" src="https://oos-cn.ctyunapi.cn/front-end/static/static/gift.png"
											mode="heightFix" v-else></image>
							<text class="sp">￥</text>
							{{ siteItemData.discountPriceStr }}
							<text class="sp">起</text>
							<text class="originalPrice">￥{{ 
							siteItemData.gunPriceInfo.slowItem.currentPriceStr ||
							siteItemData.gunPriceInfo.fastItem.currentPriceStr ||
							siteItemData.gunPriceInfo.superItem.currentPriceStr
							}}起</text>
						</view>
						<view v-else class="price">
							<text class="sp">￥</text>
							{{ siteItemData.discountPriceStr == null ? 0 : siteItemData.discountPriceStr }}
							<text class="sp">起</text>
						</view>
					</view> -->



					<!-- 831价格展示 -->
					<template v-if="siteItemData.gunPriceInfo.lowestPriceItem">
						<!-- 先判断 是否有专享价 -->
						<view class="price_view" v-if="siteItemData.gunPriceInfo.lowestPriceItem.exclusiveDiscount">
							<view class="discount_view">
								<view class="text_view">
									¥<text
										class="v_text">{{ siteItemData.gunPriceInfo.lowestPriceItem.currentPriceStr }}</text>起
								</view>
							</view>
							<view class="img_view_831_bg">
								<image class="v_icon"
									src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/bgTag/zxj_bg.png"
									mode="scaleToFill" />
								<view class="v_text">
									<text>
										¥{{ siteItemData.gunPriceInfo.lowestPriceItem.exclusivePriceStr }}起
									</text>
								</view>
							</view>
						</view>
						<!-- 831价格展示 -->
						<view class="price_view" v-else>
							<!-- 专享价没有 站点优惠价和大客户价都显示 -->
							<!-- 1,站点优惠有的情况显示站点优惠价格,否则显示当前价格 -->
							<!-- 2,站点优惠或集团优惠有的情况才显示划线价 -->
							<!-- 3,集团优惠有的情况才显示大客户字段 -->
							<view class="zxj_view_no">
								<view class="discount_view">
									<view class="text_view">
										¥<text
											class="v_text">{{ siteItemData.gunPriceInfo.lowestPriceItem.discount ? siteItemData.gunPriceInfo.lowestPriceItem.discountPriceStr : siteItemData.gunPriceInfo.lowestPriceItem.currentPriceStr}}</text>起
									</view>
								</view>
								<!-- 划线价展示：站点优惠 || 成长会员折扣 || 大客户价 -->
								<!-- 23.11.22 付费会员不显示划线价 -->
								<view class="hxj_view"
									v-if="siteItemData.gunPriceInfo.lowestPriceItem.discount || siteItemData.gunPriceInfo.lowestPriceItem.contractDiscount || siteItemData.gunPriceInfo.lowestPriceItem.growthleDiscount">
									<text class="v_text">
										¥{{ siteItemData.gunPriceInfo.lowestPriceItem.currentPriceStr }}起
									</text>
								</view>
								<!-- 大客户价展示条件 -->
								<view class="img_view_831_bg"
									v-if="siteItemData.gunPriceInfo.lowestPriceItem.contractDiscount">
									<image class="v_icon"
										src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/bgTag/dkh_bg.png"
										mode="scaleToFill" />
									<view class="v_text">
										<text>
											¥{{ siteItemData.gunPriceInfo.lowestPriceItem.contractPriceStr }}起
										</text>
									</view>
								</view>
								<!-- 成长会员价展示 -->
								<view class="img_view_831_bg"
									v-if="siteItemData.gunPriceInfo.lowestPriceItem.growthleDiscount">
									<image class="v_icon"
										src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/bgTag/icon-huiyuan.png"
										mode="scaleToFill" />
									<view class="v_text">
										<text>
											¥{{ siteItemData.gunPriceInfo.lowestPriceItem.growthlePriceStr }}起
										</text>
									</view>
								</view>
								<!-- 付费会员价展示 -->
								<view class="img_view_831_bg"
									v-if="siteItemData.gunPriceInfo.lowestPriceItem.payleDiscount">
									<image class="v_icon"
										src="https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/bgTag/icon-vip.png"
										mode="scaleToFill" />
									<view class="v_text">
										<text>
											¥{{ siteItemData.gunPriceInfo.lowestPriceItem.paylePriceStr }}起
										</text>
									</view>
								</view>
							</view>
						</view>
					</template>
					<template v-else>
						<view class="price_view">
							<view class="discount_view">
								<view class="text_view">
									¥<text class="v_text">0.00</text>起
								</view>
							</view>
						</view>
					</template>


					<view class="exceed">
						<!-- 超 -->
						<view class="exceed-item" v-if="siteItemData.gunPriceInfo.superItem">
							<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/exceed.png"
								mode="aspectFill"></image>
							<text>闲{{ siteItemData.gunPriceInfo.superItem.freeGunCount }}</text>
							<text class="text-color4">/共{{ siteItemData.gunPriceInfo.superItem.gunCount }}</text>
						</view>
						<!-- 快 -->
						<view class="exceed-item" v-if="siteItemData.gunPriceInfo.fastItem">
							<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/fast.png" mode="aspectFill">
							</image>
							<text>闲{{ siteItemData.gunPriceInfo.fastItem.freeGunCount }}</text>
							<text class="text-color4">/共{{ siteItemData.gunPriceInfo.fastItem.gunCount }}</text>
						</view>
						<!-- 慢 -->
						<view class="exceed-item" v-if="siteItemData.gunPriceInfo.slowItem">
							<image src="https://oos-cn.ctyunapi.cn/front-end/static/static/slow.png" mode="aspectFill">
							</image>
							<text>闲{{ siteItemData.gunPriceInfo.slowItem.freeGunCount }}</text>
							<text class="text-color4">/共{{ siteItemData.gunPriceInfo.slowItem.gunCount }}</text>
						</view>
					</view>
				</view>

				<image
					v-if="site_pattern === 'SUPER_FAST_SLOW_PATTERN' && site_pattern_flag && siteItemData.fastSlow == 'overTake'"
					class="tip-icon"
					:src="configPatternIcon.SUPER_CORNER_MARK || 'https://oos-cn.ctyunapi.cn/front-end/static/static/site_tips1.png'"
					mode="aspectFill"></image>
				<image
					v-if="site_pattern === 'IS_ACTIVITY_PATTERN' && site_pattern_flag && (siteItemData.discount || siteItemData.contractDiscount)"
					class="tip-icon"
					:src="configPatternIcon.ACTIVITY_CORNER_MARK || 'https://oos-cn.ctyunapi.cn/front-end/static/static/site_tips2.png'"
					mode="aspectFill"></image>
			</view>
		</view>





		<!-- 灰色遮罩，防止误触，可加可不加 -->
		<view class="mask" v-if="showDialog"></view>
		<!-- 自定义的弹窗 -->
		<view class="windows" v-if="showDialog">
			<view class="tips">确定取消收藏此站点吗</view>
			<view class="btn">
				<button class="Button1" @tap="onClick_1">
					<text class="word1">取消</text>
				</button>
				<button class="Button2" @tap="onClick_2">
					<text class="word2">确定</text>
				</button>
			</view>
		</view>

		<!-- 下端导航栏 -->
		<Tabbar :currentPage="1"></Tabbar>
	</view>
</template>

<script>
	'use strict';
	import Tabbar from '@/components/tabbar/tabbar';
import siteLabelSelection from '@/components/siteLabelSelection/siteLabelSelection';

	import {
	indexStationNewV2,
	indexStationNewV2NoAuth,
} from '@/api/mobileUpdate';

	// #ifdef H5
	import { nativeCall } from '@/utils/cdgjH5toApp.js';
import { toCDGJWechatMiniLocation } from "@/utils/h5.js";
	var script = document.createElement("script");
	script.type = "text/javascript";
	// script.async = true;
	script.src = "https://webapi.amap.com/maps?v=2.0&key=af4b606edeb4b8e1a1daf2b8d919c1d5&plugin=AMap.MarkerCluster";
	document.head.appendChild(script);
	// #endif

	// exports.__esModule = true; // pages/site/index.ts
	//首页
	//index.js
	//获取应用实例

	var app = getApp();
	var https_1 = require('./../../api/https.js');
	var util_1 = require('./../../utils/util.js');

	export default {
		components: {
			Tabbar,
			siteLabelSelection,
		},
		data() {
			return {
				_mapContextApp: null,
				pageNo: 1,
				isToken: false,
				cityname: '城市',
				current: 0,
				areaId: 0,
				showSiteDetail: undefined,
				showPreference: false,
				showRegion: false,
				chargingIndex: -1,
				disStatus: false,
				location: {},
				checkedDistance: 10,
				toolAnimation: null,
				display: false,
				markers: [],
				showLocation: true,

				siteItemData: {
					// id: '',
					// name: '',
					// latitude: '',
					// longitude: '',
					// street: '',
					// area: false,
					// fastSlow: '',
					// stationType: '',
					// image: false,
					// timeList: [],

					// gunPriceInfo: {
					// 	superItem: {
					// 		freeGunCount: '',
					// 		gunCount: ''
					// 	},

					// 	fastItem: {
					// 		freeGunCount: '',
					// 		gunCount: ''
					// 	},

					// 	slowItem: {
					// 		freeGunCount: '',
					// 		gunCount: ''
					// 	}
					// },

					// isCollection: '',
					// discount: false,
					// currentPrice: '',
					// isUniformPrice: '',
					// stationLabel: [],
					// parkingFeeDesc: '',
					// notice: '',
					// stationLabelList: [],
					// tagList: []
				},

				popupAnimation: null,
				siteDetails: {},
				readStatus: false,

				chargingTypeList: [{
						img: 'https://oos-cn.ctyunapi.cn/front-end/static/static/tagging1.png',
						name: '超充',
						key: 'overTake'
					},
					{
						img: 'https://oos-cn.ctyunapi.cn/front-end/static/static/tagging2.png',
						name: '快充',
						key: 'kuai'
					},
					{
						img: 'https://oos-cn.ctyunapi.cn/front-end/static/static/tagging3.png',
						name: '慢充',
						key: 'man'
					}
				],
				chargingTypeList2: [{
						img: 'https://oos-cn.ctyunapi.cn/front-end/static/static/tagging2.png',
						name: '有活动',
						key: 3
					},
					{
						img: 'https://oos-cn.ctyunapi.cn/front-end/static/static/tagging1.png',
						name: '无活动',
						key: 5
					}
				],

				latitude: '',
				longitude: '',
				textData: {},
				regionList: [],
				areaIdList: [],
				collectionId: 0,
				showDialog: false,

				memberQueryPreferenceDto: {
					distance: null,
					fastSlow: null,
					stationType: null,
					construction: null,
					discount: null
				},

				sortMode: 0,

				distanceList: {
					name: '距离',
					list: [{
							value: '不限',
							key: null
						},
						{
							value: '1KM',
							key: 1
						},
						{
							value: '3KM',
							key: 3
						},
						{
							value: '5KM',
							key: 5
						},
						{
							value: '10KM',
							key: 10
						},
						{
							value: '20KM',
							key: 20
						},
						{
							value: '50KM',
							key: 50
						},
						{
							value: '100KM',
							key: 100
						}
					]
				},

				siteTypeList: {
					name: '站点类型',
					list: [{
							value: '不限',
							key: null
						},
						{
							value: '公共',
							key: 1
						},
						{
							value: '个人',
							key: 2
						},
						{
							value: '公交',
							key: 3
						},
						{
							value: '环卫',
							key: 4
						},
						{
							value: '物流',
							key: 5
						},
						{
							value: '出租车',
							key: 6
						},
						{
							value: '其他',
							key: 7
						}
					]
				},

				chargingModeList: {
					name: '充电模式',
					list: [{
							value: '不限',
							key: null
						},
						{
							value: '超充',
							key: 'overTake'
						},
						{
							value: '快充',
							key: 'kuai'
						},
						{
							value: '慢充',
							key: 'man'
						}
					]
				},

				constructionSiteList: {
					name: '建设场所',
					list: [{
							value: '不限',
							key: null
						},
						{
							value: '居民区',
							key: 1
						},
						{
							value: '公共机构',
							key: 2
						},
						{
							value: '企事业单位',
							key: 3
						},
						{
							value: '写字楼',
							key: 4
						},
						{
							value: '工业园区',
							key: 5
						},
						{
							value: '交通枢纽',
							key: 6
						},
						{
							value: '大型文体设施',
							key: 7
						},
						{
							value: '城市绿地',
							key: 8
						},
						{
							value: '大型建筑配件停车场',
							key: 9
						},
						{
							value: '路边停车位',
							key: 10
						},
						{
							value: '城际高速服务区',
							key: 11
						},
						{
							value: '其他',
							key: 12
						}
					]
				},

				discountList: {
					name: '优惠',
					list: [{
							value: '不限',
							key: 2
						},
						{
							value: '有优惠',
							key: 3
						},
						{
							value: '无优惠',
							key: 5
						}
					]
				},

				id: '',
				time: '',

				t: {
					name: '',
					color: ''
				},

				message: false,
				noticeList: [],
				h5_cluster: null,
				site_pattern: 'SUPER_FAST_SLOW_PATTERN',
				site_pattern_flag: true,
				markersList: [],
				tapItemMarker: null,
				configPatternIcon: null,
				configClusterIcon: null,
				getStationType: 2
			};
		},
		async onLoad() {
			this.createMap()
			const pattern_res = await this.getPattern();
			if (pattern_res.code === 0) {
				this.site_pattern = pattern_res.data.mapPatternEnum || 'SUPER_FAST_SLOW_PATTERN';
				this.site_pattern == 'IS_ACTIVITY_PATTERN' ? this.getStationType = 6 : this.getStationType = 2;
				this.site_pattern_flag = pattern_res.data.cornerFlag;
			}
			const icon_res = await this.getIconMap();
			if (icon_res.code === 0) {
				this.configClusterIcon = icon_res.data.MAP_AGGREGATION;
				if (icon_res.data.ACTIVITY_PATTERN) {
					this.configPatternIcon = icon_res.data.ACTIVITY_PATTERN;
					this.chargingTypeList2 = this.chargingTypeList2.map(item => {
						if (item.key === 5 && icon_res.data.ACTIVITY_PATTERN.RULE_SCREEN_ICON) {
							item.img = icon_res.data.ACTIVITY_PATTERN.RULE_SCREEN_ICON;
						} else if (item.key === 3 && icon_res.data.ACTIVITY_PATTERN.ACTIVITY_SCREEN_ICON) {
							item.img = icon_res.data.ACTIVITY_PATTERN.ACTIVITY_SCREEN_ICON;
						}
						return item;
					})
				} else if (icon_res.data.SUPER_FAST_SLOW_PATTERN) {
					this.configPatternIcon = icon_res.data.SUPER_FAST_SLOW_PATTERN;
					this.chargingTypeList = this.chargingTypeList.map(item => {
						if (item.key === 'overTake' && icon_res.data.SUPER_FAST_SLOW_PATTERN
							.SUPER_SCREEN_ICON) {
							item.img = icon_res.data.SUPER_FAST_SLOW_PATTERN.SUPER_SCREEN_ICON;
						} else if (item.key === 'kuai' && icon_res.data.SUPER_FAST_SLOW_PATTERN
							.FAST_SCREEN_ICON) {
							item.img = icon_res.data.SUPER_FAST_SLOW_PATTERN.FAST_SCREEN_ICON;
						} else if (item.key === 'man' && icon_res.data.SUPER_FAST_SLOW_PATTERN
							.SLOW_SCREEN_ICON) {
							item.img = icon_res.data.SUPER_FAST_SLOW_PATTERN.SLOW_SCREEN_ICON;
						}
						return item;
					})
				}
			}
			// uni.$on('cityname', (data) => {
			// 	this.cityname = data.cityname
			// })
			this.setMapData('site_pattern')
			this.setMapData('site_pattern_flag')
			this.setMapData('mixOtherIconList')
			this.setMapData('configClusterIcon')
			this.setMapData('configPatternIcon')
			this.setMapData('chargingTypeList2')
			this.setMapData('chargingTypeList')



			// methods
			this.setMapData('markertap')
			this.setMapData('centralPoint')

			this.getMapData('_mapContextApp')





			// uni.$on('siteItemData', (data) => {
			// 	console.log("接收siteItemData数据",data.siteItemData)
			// 	this.showSiteDetail = true //详情弹窗
			// 	this.siteItemData = data.siteItemData
			// })
			// uni.$on('sendData', res => {
			// 	let {key, type, index} = res
			// 	if (key === null) {
			// 		this.checkChargingType1()
			// 	} else {
			// 		let e = {
			// 			currentTarget: {
			// 				dataset: {
			// 					index, key, type
			// 				}
			// 			}
			// 		}
			// 		this.checkChargingType(e)
			// 	}
			// })
			// uni.$on('pointData', res => {
			// 	if (res.pointStatus) {
			// 		this.centralPoint()
			// 	}
			// })

			app.globalData.updateManager();

			//#ifdef APP-PLUS
			let result = await this.$store.dispatch("requestPermissions", 'ACCESS_FINE_LOCATION')
			//#endif 

			// uni.showLoading({
			//     title: '加载中',
			//     mask: true
			// });
		},
		onShow: function() {
			uni.hideTabBar()
			console.log('設置陳工啦', this.centralPoint)


			let getMemberQueryPreferenceDto = uni.getStorageSync('siteFiltering')

			this.$nextTick(() => {
				this.$refs.siteLabelSelectionRef.getIndexSearchCondition()
			})


			//#ifndef APP-PLUS
			if (uni.getStorageSync('cityName')) {
				this.cityname = uni.getStorageSync('cityName')
				this.gaode()
			} else {
				this.cityname = uni.getStorageSync('currentCityName')
				//获取用户是否开gps或定位
				this.getLocaltion()
			}
			//#endif

			// 

			//#ifdef APP-PLUS
			// this.setMapData('cityname',this.cityname)


			if (uni.getStorageSync('cityName')) {
				this.cityname = uni.getStorageSync('cityName')
				this.gaode()
			} else {
				this.cityname = uni.getStorageSync('cityName') || uni.getStorageSync('currentCityName')
				app.globalData.getCity(() => {
					// uni.$emit('upDataMap')
					this.gaode()
				})
			}


			//#endif

			this.setData({
				// cityname: uni.getStorageSync('cityName') || uni.getStorageSync('currentCityName'),
				isToken: uni.getStorageSync('token')
			});
			this.setMapData('isToken')


			if (uni.getStorageSync('token')) {
				this.queryNewMessage();
				this.getMemberQueryPreference();
				this.getIsRead();
				this.getAreaList();
			}
		},
		// 页面卸载
		onUnload: function() {
			uni.hideLoading();
		},
		created() {
			//每次切换只执行一次
			// uni.$on('upDataMap', this.gaode)
		},
		methods: {
			setMapData(key) {
				uni.$emit('APPMAP' + key, this[key])
			},
			getMapData(key) {
				uni.$on('APPMAP' + key, (value) => {
					this[key] = value
				})
			},
			// 取消存储在globalData.requestTasks的网络请求
			abortRequestTasks() {
				getApp().globalData.requestTasks.forEach(item => {
					item.abort()
				})
				getApp().globalData.requestTasks = []
			},
			// 关闭弹窗
			closeSiteModal() {
				this.setData({
					showSiteDetail: false
				});
			},
			// 重新获取定位
			getLocaltion(cb) {
				let that = this;
				//获取uni设置的 userLocation
				// #ifdef H5
				app.globalData.getCity(() => {
					that.gaode()
				}, true);
				that.cityname = uni.getStorageSync('cityName') ? uni.getStorageSync('cityName') : uni.getStorageSync(
					'currentCityName')
				return
				// #endif
				// #ifdef MP-WEIXIN
				console.log(uni.getStorageSync('cityName'), '当前城市')
				uni.getSetting({
					success: function(res) {
						console.log(res, res.authSetting['scope.userLocation'], 'fjdskfljdskfl')
						that.openLocationSetting(res.authSetting['scope.userLocation'])
					}
				});

				// #endif

				// #ifdef MP-ALIPAY
				uni.getSetting({
					withSubscriptions: true, // 是否同时获取用户订阅消息的订阅状态，默认不获取
					success: (res) => {
						const {
							location = false
						} = res.authSetting;
						console.log("getLocationStatus",location)
						this.openLocationSetting(location)
					},
					fail: err => {
						console.error('--getSetting--',err);
					}
				});
				// #endif
				

				//重新自身定位后
				that.cityname = uni.getStorageSync('cityName') ? uni.getStorageSync('cityName') : uni.getStorageSync(
					'currentCityName')

				// //再次渲染地图
				// that.centralPoint()
			},
			
			openLocationSetting(getLocationStatus){
				if (!getLocationStatus) {
					uni.showModal({
						title: '位置授权说明',
						content: '需要获取您的地理位置，以精确获取周边充电站信息，否则无法准确查询附近充电桩资源。',
						confirmText: '确认',
						confirmColor: uni.getStorageSync('textColor') || '#6DB12E',
						cancelText: '取消',
						success: function(res) {
							console.log(res, '')
							if (res.confirm) {
								console.log('确认后去小程序设置授权')
								uni.openSetting({
									success(res) {
										console.log(res.authSetting)
									}
								});
				
							} else if (res.cancel) {
								console.log('site取消后去首页22')
								uni.switchTab({
									url: '/pages/index/index'
								});
							}
						}
					});
				} else {
					console.log('信号弱,site其实已经打开了定位权限....')
					//请求地图散点数据	
					// if(uni.getStorageSync('cityName')){
					// 	that.gaode()
					// 	console.log(uni.getStorageSync('cityName'),'切换城市')
					// }else{
					app.globalData.getCity(() => {
						this.gaode()
						this._mapContext.moveToLocation();
					}, true);
					console.log(uni.getStorageSync('cityName'), '当前城市')
					// }
				
				}
			},

			// 是否有活动模式
			getPattern() {
				return https_1.getNowSwitchPattern({
					sellerId: app.globalData.sellerId
				})
			},
			// 获取后台配置图标
			getIconMap() {
				let pattern = this.site_pattern === 'IS_ACTIVITY_PATTERN' ? 'ACTIVITY_PATTERN' : 'SUPER_FAST_SLOW_PATTERN';
				return https_1.getIconMap({
					sellerId: app.globalData.sellerId,
					twoEnums: 'MAP_AGGREGATION,' + pattern
				})
			},
			//获取站点数据
			getStationPage() {
				console.log('getStationPage获取站点数据中')
				if (this.pageNo === 1) {
					uni.showLoading({
						title: '加载中',
						mask: true
					});
					console.log('加载中加载中加载中1111111111111111111111')
				}
				const that = this;
				// let cityName = uni.getStorageSync('cityName') || uni.getStorageSync('currentCityName');
				//经纬度有无
				let latLongState = !!(uni.getStorageSync('latitude') && uni.getStorageSync('longitude'))
				if (latLongState) {
					// 获取站点列表v2
					let siteFiltering = uni.getStorageSync('siteFiltering');
					let siteLabelSelection = uni.getStorageSync('siteLabelSelection');
					let tagFilter = {
						...siteFiltering,
						...siteLabelSelection
					}
					if (siteFiltering.gunType && siteLabelSelection.gunType) {
						tagFilter.gunType = [...siteFiltering.gunType, ...siteLabelSelection.gunType]
					}
					if (siteFiltering.serviceFacilities && siteLabelSelection.serviceFacilities) {
						tagFilter.serviceFacilities = [...siteFiltering.serviceFacilities, ...siteLabelSelection
							.serviceFacilities
						]
					}

					let datas = {
						"sellerId": getApp().globalData.sellerId,
						"areaId": uni.getStorageSync('cityId') || getApp().globalData.cityId,
						"latitude": uni.getStorageSync('latitude'),
						"longitude": uni.getStorageSync('longitude'),
						"current": this.pageNo,
						"pageSize": 10,
						"sortMode": 3,
						"isCollect": false,
						...tagFilter,
					}
					console.log(datas, 'site-index站点筛选条件.....');

					let getApiUrl = uni.getStorageSync('token') ? indexStationNewV2 : indexStationNewV2NoAuth
					getApiUrl({
							...datas
						}, true)
						.then((res) => {
							console.log('站桩站点..............................123', res, '站桩站点.........');
							if (res.code == 0 && res.data.data) {
								uni.hideLoading()
								const data = res.data.data || [];
								if (that.pageNo == 1) {
									//默认展示第一条数据
									let morenSiteDetail = data[0]

									that.setMapData('morenSiteDetail')

									let target = {
										detail: {
											markerId: morenSiteDetail.id
										}
									}
									that.markertap(target)
								}


								// if(that.siteItemData){
								// console.log(that.siteItemData, '站点详情第一个有数据==>弹窗....')
								// that.setData({
								// 	showSiteDetail: true
								// });
								// }


								let markers = [];

								// #ifdef APP-PLUS || MP-WEIXIN || MP-ALIPAY
								const marker = {
									width: 35,
									height: 40,
									joinCluster: true,
									iconPath: ''
								}
								markers = data.map(item => {
									marker.latitude = Number(item.latitude);
									marker.longitude = Number(item.longitude);

									// 831版本 站点列表取消了超快慢的字段, 所以散点图标写死一个,不根据类型
									marker.iconPath =
										'https://oos-cn.ctyunapi.cn/front-end/static/mobileImg/site_icon_lv.png';


									// if (that.site_pattern === 'IS_ACTIVITY_PATTERN') {
									// 	if (item.discount || item.contractDiscount) {
									// 		marker.iconPath = that.configPatternIcon.ACTIVITY_SMALL_ICON || 'https://oos-cn.ctyunapi.cn/front-end/static/static/marker4.png';
									// 	} else {
									// 		marker.iconPath = that.configPatternIcon.RULE_SMALL_ICON || 'https://oos-cn.ctyunapi.cn/front-end/static/static/marker3.png';
									// 	}
									// } else {
									// if (item.fastSlow == 'overTake') {
									// 	marker.iconPath = that.configPatternIcon.SUPER_SMALL_ICON || 'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_blue_s.png';
									// } else if (item.fastSlow == 'kuai') {
									// 	marker.iconPath = that.configPatternIcon.FAST_SMALL_ICON || 'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_red_s.png';
									// } else if (item.fastSlow == 'man') {
									// 	marker.iconPath = that.configPatternIcon.SLOW_SMALL_ICON || 'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_green_s.png';
									// }
									// }
									return {
										...item,
										...marker
									}
								})

								// #ifndef MP-ALIPAY
								that._mapContext.addMarkers({
									markers,
									clear: that.pageNo === 1 ? true : false
								});
								// #endif

								// #ifdef MP-ALIPAY
								that._mapContext.updateComponents({
									markers,
									clear: that.pageNo === 1 ? true : false
								});
								// #endif


								// #endif

								// #ifdef H5
								markers = data.map(item => {
									const marker = {
										lnglat: [],
										iconPath: '',
										id: item.id
									}
									marker.lnglat.push(item.longitude, item.latitude);
									if (that.site_pattern === 'IS_ACTIVITY_PATTERN') {
										if (item.discount || item.contractDiscount) {
											marker.iconPath = that.configPatternIcon.ACTIVITY_SMALL_ICON ||
												'https://oos-cn.ctyunapi.cn/front-end/static/static/marker4.png';
										} else {
											marker.iconPath = that.configPatternIcon.RULE_SMALL_ICON ||
												'https://oos-cn.ctyunapi.cn/front-end/static/static/marker3.png';
										}
									} else {
										if (item.fastSlow == 'overTake') {
											marker.iconPath = that.configPatternIcon.SUPER_SMALL_ICON ||
												'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_blue_s.png';
										} else if (item.fastSlow == 'kuai') {
											marker.iconPath = that.configPatternIcon.FAST_SMALL_ICON ||
												'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_red_s.png';
										} else if (item.fastSlow == 'man') {
											marker.iconPath = that.configPatternIcon.SLOW_SMALL_ICON ||
												'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_green_s.png';
										}
									}
									return marker;
								});
								that.h5MarkerCluster(JSON.parse(JSON.stringify([...that.markersList, ...markers])));
								// #endif

								that.markersList = [...that.markersList, ...markers];
								that.setMapData('markersList')

								that.cityname = uni.getStorageSync('cityName') ? uni.getStorageSync('cityName') : uni
									.getStorageSync('currentCityName')
								that.setMapData('cityname')

								if (that.markersList.length < res.data.totalCount) {
									setTimeout(() => {
										console.log('执行汇总请求数据中，，，，，', res.data.totalCount)
										that.pageNo = that.pageNo + 1
										that.setMapData('pageNo')
										that.getStationPage()
									}, 100)
								} else {

								}
							} else {
								console.log('site站点的数据为null.....')
								uni.hideLoading()

								that.markersList = [];
								that.setMapData('markersList')
								that.showSiteDetail = false;
								that.setMapData('showSiteDetail')

								// #ifndef MP-ALIPAY
								that._mapContext.addMarkers({
									markers: that.markersList,
									clear: true
								});
								// #endif

								// #ifdef MP-ALIPAY
								that._mapContext.updateComponents({
									markers:that.markersList,
									clear: true
								});
								// #endif
							}
						});

				} else {
					console.log('经纬度为空不去调取...', latLongState)
				}
			},
			// 高德点聚合-H5
			h5MarkerCluster(markers) {
				console.log('h5地图聚合', markers)
				const that = this;
				let cluster;
				if (this.h5_cluster) {
					this.h5_cluster.setMap(null);
				}
				let _renderClusterMarker = function(context) {
					var clusterCount = context.count;
					var width, height,
						div = document.createElement('div'),
						img = document.createElement('img'),
						span = document.createElement('span');

					if (clusterCount > 99) {
						width = 40;
						height = 47;
						img.src = that.configClusterIcon.THREE_AGGREGATION_ICON ||
							'https://oos-cn.ctyunapi.cn/front-end/static/static/marker2.png';
						span.style.cssText =
							'position: absolute; left: 2px; top: 2px; width: 36px; height: 36px; line-height: 36px; color: #73A843; font-size: 12px; text-align: center;';
					} else {
						width = 36;
						height = 41;
						img.src = that.configClusterIcon.TWO_AGGREGATION_ICON ||
							'https://oos-cn.ctyunapi.cn/front-end/static/static/marker1.png';
						span.style.cssText =
							'position: absolute; left: 3px; top: 2px; width: 30px; height: 30px; line-height: 30px; color: #ffffff; font-size: 13px; text-align: center;';
					}
					div.style.cssText = `width: ${width}px; height: ${height}px; position: relative`;
					img.style.cssText = 'height: 100%; width: 100%;';
					span.innerHTML = clusterCount;
					div.appendChild(img);
					div.appendChild(span);
					context.marker.setOffset(new AMap.Pixel(-width / 2, -height / 2));
					context.marker.setContent(div);

					context.marker.on('click', function(e) {
						let curZoom = that._mapContext.getZoom();
						if (curZoom < 20) {
							curZoom += 1;
						}
						that._mapContext.setZoomAndCenter(curZoom, e.lnglat);
					});
				};
				let _renderMarker = function(context) {
					var content = `<img style="height: 26px; width: 20px;" src="${ context.data[0].iconPath }" />`;
					var offset = new AMap.Pixel(-10, -13);
					context.marker.setContent(content)
					context.marker.setOffset(offset)
					context.marker.on('click', function(e) {
						let target = {
							detail: {
								markerId: context.data[0].id
							}
						}
						that.markertap(target)
					})
				}
				this._mapContext.plugin(["AMap.MarkerCluster"], () => {
					this.h5_cluster = new AMap.MarkerCluster(this._mapContext, markers, {
						gridSize: 60,
						renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式
						renderMarker: _renderMarker, // 自定义非聚合点样式
					});
				})
			},
			//公告
			queryNewMessage: function() {
				var that = this;
				https_1.queryNewMessage({}).then(function(res) {
					if (res.code == 0) {
						if (res.data != null && res.data.length != 0) {
							that.message = true,
								that.noticeList = res.data
						} else {
							that.message = false
						}
					} else {
						that.message = false
					}
					uni.$emit('message', {
						message: that.message,
						noticeList: that.noticeList
					})
				});
			},
			//公告详情
			noticeDetails: function(e) {
				const item = e.currentTarget.dataset.item;

				uni.navigateTo({
					url: '/homeSub/pages/platformAnnouncement/platformAnnouncement?id=' + item.id
				});
			},
			nvueShow: function() {
				const subnvue = uni.getSubNVueById('drawer') // 获取nvue
				subnvue.show() // 显示nvue
			},
			//站点详情
			handleToDetails: function({
				id,
				terminalType
			}) {
				this.setData({
					id: id
				});
				// app.globalData.CHECK_LOGIN(function () {
				if (terminalType === 2) {
					uni.navigateTo({
						url: '/homeSub/pages/eBikeSiteDetail/eBikeSiteDetail?stationId=' + id
					});
				} else {
					uni.navigateTo({
						url: '/homeSub/pages/siteDetail/siteDetail?stationId=' + id
					});
				}
				// });
			},

			// 导航
			goAddress: function(e) {
				var latitude = parseFloat(e.currentTarget.dataset.latitude);
				var longitude = parseFloat(e.currentTarget.dataset.longitude);
				var name = e.currentTarget.dataset.name;
				var street = e.currentTarget.dataset.street;
				
				// #ifdef H5 
				var clientType = uni.getStorageSync("clientType");
				if (clientType == "APP" && this.isCdgj()) {
					this.callNative({
						lat: latitude,
						lng: longitude,
						address: street,
					});
					return;
				} else if (clientType == "WeChat" && this.isCdgj()) {
					toCDGJWechatMiniLocation({
						lat: latitude,
						lng: longitude,
						address: street,
					})
					return;
				}
				// #endif

				uni.openLocation({
					latitude: latitude,
					longitude: longitude,
					name: name,
					address: name
				});
			},

			callNative(params) {
				nativeCall("openMap", params);
			},

			//取消-弹窗
			onClick_1: function() {
				this.setData({
					showDialog: false
				});
			},

			//调起-弹窗
			cancelCollection: function(e) {
				var that = this;
				app.globalData.CHECK_LOGIN(function() {
					that.setData({
						collectionId: e.currentTarget.dataset.id,
						showDialog: true
					});
				});
			},

			//确定取消收藏-弹窗
			onClick_2: function() {
				var that = this;
				https_1.cancelCollectStation(this.collectionId).then(function(res) {
					if (res.code == 0) {
						var data = that.siteItemData;
						data.isCollection = false;
						that.setData({
							siteItemData: data,
							showDialog: false
						});
					}
				});
			},

			//收藏
			collection: function(e) {
				var that = this;
				app.globalData.CHECK_LOGIN(function() {
					var id = e.currentTarget.dataset.id;
					https_1.collectStation(id).then(function(res) {
						if (res.code == 0) {
							var data = that.siteItemData;
							data.isCollection = true;
							that.setData({
								siteItemData: data
							});
						}
					});
				});
			},

			getIsRead: function() {
				var that = this;
				https_1
					.isRread({})
					.then(function(res) {
						if (res.code == 0) {
							that.setData({
								readStatus: res.data
							});
						}
					})['catch'](function(err) {});
			},

			//选择地区
			checkArea: function(e) {
				var id = e.currentTarget.dataset.id;
				var list = this.regionList;
				var areaIdList = [];
				list.forEach(function(element) {
					if (element.id == id) {
						element.isCheck = !element.isCheck;
						list[0].isCheck = false;
					}
				});

				if (id == 0) {
					list.forEach(function(element) {
						list[0].isCheck = true;
						element.isCheck = false;
					});
				}

				list.forEach(function(element, index) {
					if (element.isCheck && index > 0) {
						areaIdList.push(element.id);
						areaIdList.map(Number);
					}
				});
				this.setData({
					regionList: list,
					areaIdList: areaIdList
				});
			},

			//选择距离
			checkDistance: function(e) {
				var key = e.currentTarget.dataset.key;
				uni.$emit('distance', {
					key: key
				})
				this.setData({
					'memberQueryPreferenceDto.distance': key
				});
			},

			//选择站点类型
			checkSiteType: function(e) {
				var key = e.currentTarget.dataset.key;
				uni.$emit('stationType', {
					key: key
				})
				this.setData({
					'memberQueryPreferenceDto.stationType': key
				});
			},

			//选择充电模式
			checkChargingMode: function(e) {
				var key = e.currentTarget.dataset.key;
				uni.$emit('fastSlow', {
					key: key
				})
				this.setData({
					'memberQueryPreferenceDto.fastSlow': key
				});
			},

			//选择建设场所
			checkConstructionSite: function(e) {
				var key = e.currentTarget.dataset.key;
				uni.$emit('construction', {
					key: key
				})
				this.setData({
					'memberQueryPreferenceDto.construction': key
				});
			},

			//选择有无优惠
			checkIsDiscount: function(e) {
				var key = e.currentTarget.dataset.key;
				this.setData({
					'memberQueryPreferenceDto.discount': key
				});
			},

			//根据区域名获取区域
			getAreaList: function() {
				var that = this;
				https_1
					.getAreaList({
						pId: uni.getStorageSync('cityId')
					})
					.then(function(res) {
						if (res.code == 0) {
							var list = res.data;
							list.forEach(function(element) {
								element.isCheck = false;
							});
							list.unshift({
								id: 0,
								name: '全部区',
								isCheck: true
							});
							that.setData({
								regionList: list
							});
						}
					});
			},

			// 获取用户偏好
			getMemberQueryPreference: function() {
				var that = this;
				https_1.getMemberQueryPreference({}).then(function(res) {
					if (res.code == 0) {
						var data = res.data;
						that.setData({
							'memberQueryPreferenceDto.construction': data.construction || null,
							'memberQueryPreferenceDto.distance': data.distance || null,
							'memberQueryPreferenceDto.fastSlow': data.fastSlow || null,
							'memberQueryPreferenceDto.stationType': data.stationType || null
						});
					}
				});
			},

			//站点列表
			goSiteList: function() {
				var that = this;
				app.globalData.CHECK_LOGIN(function() {
					uni.navigateTo({
						url: '/packageFunctional/sitelist/sitelist'
					});
					that.setData({
						showPreference: false,
						showRegion: false
					});
					uni.$emit('check-popup', {
						status: false,
					});
				});
			},

			//定位
			goLocation: function() {
				// app.globalData.CHECK_LOGIN(function () {
				uni.navigateTo({
					url: '../../homeSub/pages/area/area'
				});
				// });
			},

			//去搜索
			goSearch: function() {
				// app.globalData.CHECK_LOGIN(function () {
				uni.navigateTo({
					url: '../../homeSub/pages/search/search'
				});
				// });
			},

			switchMenu: function(e) {
				var index = e.currentTarget.dataset.current;
				this.setData({
					current: index || 0
				});
			},

			//展开地区
			showRegionFun: function() {
				var that = this;
				app.globalData.CHECK_LOGIN(function() {
					that.setData({
						showPreference: false,
						showRegion: true
					});
					uni.$emit('check-popup', {
						status: true,
					});
				});
			},

			//关闭地区
			onCloseRegion: function() {
				this.setData({
					showRegion: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
			},

			//清除地区
			canalRegion: function() {
				var list = this.regionList;
				list.forEach(function(element) {
					list[0].isCheck = true;
					element.isCheck = false;
				});
				this.setData({
					regionList: list,
					areaIdList: [],
					showRegion: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},

			//确定地区
			enterRegion: function() {
				this.setData({
					showRegion: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},

			//展开偏好
			showPreferenceFun: function() {

				uni.navigateTo({
					url: '/pages/siteFiltering/siteFiltering'
				});


				// this.setData({
				// 	showPreference: true,
				// 	showRegion: false
				// });
				// uni.$emit('check-popup', {
				// 	status: true,
				// });
			},

			//关闭偏好
			onClosePreference: function() {
				this.setData({
					showPreference: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
			},

			//清除偏好
			canalPreference: function() {
				this.setData({
					memberQueryPreferenceDto: {
						distance: null,
						fastSlow: null,
						stationType: null,
						construction: null,
						discount: null
					},
					showPreference: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},

			//确定偏好
			enterPreference: function() {
				this.setData({
					showPreference: false
				});
				uni.$emit('check-popup', {
					status: false,
				});
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},

			//切换充电（全部）类型
			checkChargingType1: function() {
				this.setData({
					getStationType: this.site_pattern == 'IS_ACTIVITY_PATTERN' ? 6 : 2,
					chargingIndex: -1,
					'memberQueryPreferenceDto.fastSlow': null,
					'memberQueryPreferenceDto.discount': null
				});
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},

			//切换充电（超快慢）类型
			checkChargingType: function(e) {
				var index = e.currentTarget.dataset.index;
				var key = e.currentTarget.dataset.key;
				var type = e.currentTarget.dataset.type;

				this.chargingIndex = index;
				if (type === 'activity') {
					// this.memberQueryPreferenceDto.discount = key
					this.getStationType = key
				} else {
					this.memberQueryPreferenceDto.fastSlow = key
				}
				this.pageNo = 1
				this.markersList = []
				this.abortRequestTasks()
				this.getStationPage();
			},
			//信息
			goNotice: function() {
				// // uni.showToast({
				// //   title: '暂未开放',
				// //   icon: 'error',
				// //   duration: 2000
				// // })
				// // app.globalData.CHECK_LOGIN(function () {
				// 	uni.navigateTo({
				// 		url: '../../homeSub/pages/messageCenter/messageCenter'
				// 	});
				// // });


				app.globalData.CHECK_LOGIN_Toast(() => {
					uni.navigateTo({
						url: '../../homeSub/pages/messageCenter/messageCenter'
					});
				}, '请先进行登录!')
			},

			gaode: function() {
				console.log('this.gaode-----------');
				var that = this;
				that.setData({
					latitude: uni.getStorageSync("latitude"),
					longitude: uni.getStorageSync("longitude"),
				})
				that.setMapData('latitude')
				that.setMapData('longitude')

				// h5更新地图坐标
				// #ifdef H5
				console.log('这里更新左边咯', uni.getStorageSync('longitude'), uni.getStorageSync('latitude'))
				this._mapContext && this._mapContext.setCenter([uni.getStorageSync('longitude'), uni.getStorageSync(
					'latitude')])
				// #endif

				this.pageNo = 1
				that.setMapData('pageNo')
				this.markersList = []
				that.setMapData('markersList')
				this.abortRequestTasks()
				that.getStationPage()
			},

			// 距离
			showDis: function() {
				if (!this.disStatus) {
					this.showDisAnimation('110px');
				} else {
					this.showDisAnimation('50px');
				}
			},

			// 显示距离动画
			showDisAnimation: function(height) {
				if (height == '50px') {
					this.setData({
						disStatus: false
					});
				} else {
					this.setData({
						disStatus: true
					});
				}

				var toolAnimation = uni.createAnimation({
					duration: 300,
					timingFunction: 'ease',
					delay: 10 // 多久后动画开始运行
				});
				toolAnimation.height(height).step();
				this.setData({
					toolAnimation: toolAnimation['export']()
				});
			},

			// 查询
			gosearch: function() {
				app.globalData.CHECK_LOGIN(function() {
					uni.navigateTo({
						url: '/pages/search/search'
					});
				});
			},

			// 详情
			goinfo: function() {
				app.globalData.CHECK_LOGIN(function() {
					uni.navigateTo({
						url: ''
					});
				});
			},

			// 地图渲染完成
			mapUpdated: function() {
				uni.hideLoading();
			},

			//用户点击地图mark，显示详情
			markertap: function(e) {
				console.log(e, 'markertap.....')
				var that = this;
				var csiteid = e.detail.markerId; //获取站点详情

				for (let i = 0; i < this.markersList.length; i++) {
					if (this.markersList[i].id === csiteid) {
						let itemMarker = {
							...this.markersList[i],
							width: 40,
							height: 50
						};
						if (this.site_pattern === 'IS_ACTIVITY_PATTERN') {
							if ((itemMarker.discount || itemMarker.contractDiscount) && this.configPatternIcon
								.ACTIVITY_LARGE_ICON) {
								itemMarker.iconPath = this.configPatternIcon.ACTIVITY_LARGE_ICON;
							} else if (!itemMarker.discount && !itemMarker.contractDiscount && this.configPatternIcon
								.RULE_LARGE_ICON) {
								itemMarker.iconPath = this.configPatternIcon.RULE_LARGE_ICON;
							}
						} else {
							if (itemMarker.fastSlow == 'overTake' && this.configPatternIcon.SUPER_LARGE_ICON) {
								itemMarker.iconPath = this.configPatternIcon.SUPER_LARGE_ICON;
							} else if (itemMarker.fastSlow == 'kuai' && this.configPatternIcon.FAST_LARGE_ICON) {
								itemMarker.iconPath = this.configPatternIcon.FAST_LARGE_ICON;
							} else if (itemMarker.fastSlow == 'man' && this.configPatternIcon.SLOW_LARGE_ICON) {
								itemMarker.iconPath = this.configPatternIcon.SLOW_LARGE_ICON;
							}
						}

						let itemMarkerList = Array.of(itemMarker);
						this.tapItemMarker = itemMarker;

						that.setMapData('tapItemMarker')
						console.log(itemMarkerList, '这是啥啊')

						// #ifdef H5
						// uni.$emit('markers', {
						// 	markersList: itemMarkerList
						// });
						// #endif

						// #ifdef APP-PLUS || MP-WEIXIN
						that._mapContext.addMarkers({
							markers: itemMarkerList,
							clear: false
						});
						// #endif

						// #ifdef MP-ALIPAY
						that._mapContext.updateComponents({
							markers: itemMarkerList,
							clear: false
						});
						// #endif


						break;
					}
				}

				let getStationDetailById = uni.getStorageSync('token') ? https_1.getStationDetailByIdNew : https_1
					.getStationDetailByIdNotAuth

				getStationDetailById({
						stationId: csiteid,
						latitude: uni.getStorageSync('latitude'),
						longitude: uni.getStorageSync('longitude')
					})
					.then(function(res) {
						if (res.code == 0) {
							let result = res.data;
							let arr = [];
							let arrtext = ['fastItem', 'slowItem', 'superItem']
							arrtext.forEach((item, index) => {
								if (result.gunPriceInfo[item]) {
									if (result.gunPriceInfo[item].discount || result.gunPriceInfo[item]
										.contractDiscount) {
										arr[index] = result.gunPriceInfo[item].discountPriceStr
									} else {
										arr[index] = result.gunPriceInfo[item].currentPriceStr
									}
								} else {
									arr[index] = 0
								}
							})
							// arr[0] = result.gunPriceInfo.fastItem ? result.gunPriceInfo.fastItem.currentPrice : 0
							// arr[1] = result.gunPriceInfo.slowItem ? result.gunPriceInfo.slowItem.currentPrice : 0
							// arr[2] = result.gunPriceInfo.superItem ? result.gunPriceInfo.superItem.currentPrice : 0
							arr = arr.filter(item => item > 0)
							arr.sort((a, b) => {
								return a - b
							})
							console.log(arr)
							result.discountPriceStr = arr[0] || 0
							that.setData({
								siteItemData: result,
								showSiteDetail: true
							});
							that.setMapData('siteItemData')
							that.setMapData('showSiteDetail')
							// uni.$emit('siteItemData', {
							// 	siteItemData: result
							// });
						}
					});
			},

			onCloseSiteDetail: function() {
				if (this.tapItemMarker != null) {
					setTimeout(() => {
						let itemMarker = {
							...this.tapItemMarker,
							width: 35,
							height: 40
						};
						if (this.configPatternIcon) {
							if (this.site_pattern === 'IS_ACTIVITY_PATTERN') {
								if (itemMarker.discount || itemMarker.contractDiscount) {
									itemMarker.iconPath = this.configPatternIcon.ACTIVITY_SMALL_ICON ||
										'https://oos-cn.ctyunapi.cn/front-end/static/static/marker4.png';
								} else {
									itemMarker.iconPath = this.configPatternIcon.RULE_SMALL_ICON ||
										'https://oos-cn.ctyunapi.cn/front-end/static/static/marker3.png';
								}
							} else {
								if (itemMarker.fastSlow == 'overTake') {
									itemMarker.iconPath = this.configPatternIcon.SUPER_SMALL_ICON ||
										'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_blue_s.png';
								} else if (itemMarker.fastSlow == 'kuai') {
									itemMarker.iconPath = this.configPatternIcon.FAST_SMALL_ICON ||
										'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_red_s.png';
								} else if (itemMarker.fastSlow == 'man') {
									itemMarker.iconPath = this.configPatternIcon.SLOW_SMALL_ICON ||
										'https://oos-cn.ctyunapi.cn/front-end/static/static/charge_green_s.png';
								}
							}
						}

						let itemMarkerList = Array.of(itemMarker);

						// #ifndef MP-ALIPAY
						this._mapContext.addMarkers({
							markers: itemMarkerList,
							clear: false
						});
						// #endif

						// #ifdef MP-ALIPAY
						this._mapContext.updateComponents({
							markers: itemMarkerList,
							clear: false
						});
						// #endif

						this.tapItemMarker = null;
					}, 500)
				}
				this.setData({
					showSiteDetail: false
				});
			},

			// 中心点
			centralPoint: async function() {
				console.log('fjdskaljfkdlsajfkzhongxindian ')
				var that = this;


				// #ifdef MP-WEIXIN || MP-ALIPAY

				//回来自己定位的地方 删除自己选中的定位信息
				uni.removeStorageSync('cityId');
				uni.removeStorageSync('cityName');
				uni.removeStorageSync('latitude');
				uni.removeStorageSync('longitude');
				this.getLocaltion(() => {
					this._mapContext.moveToLocation();
				})
				// #endif


				// #ifdef APP-PLUS
				//回来自己定位的地方 删除自己选中的定位信息
				uni.removeStorageSync('cityId');
				uni.removeStorageSync('cityName');
				uni.removeStorageSync('latitude');
				uni.removeStorageSync('longitude');
				this.cityname = uni.getStorageSync('cityName') || uni.getStorageSync('currentCityName')
				this.setMapData('cityname')
				let result = await this.$store.dispatch("requestPermissions", 'ACCESS_FINE_LOCATION')
				app.globalData.getCity(() => {
					this.gaode()
					console.log(this._mapContextApp)
					this._mapContextApp.moveToLocation();
				})

				// #endif

				// #ifdef H5
				this._mapContext.setCenter([uni.getStorageSync('longitude'), uni.getStorageSync('latitude')])
				// #endif
				// }
			},

			// 终端号充电
			goCode: function() {
				uni.navigateTo({
					url: '../code/code'
				});
			},

			// 创建地图
			createMap: function() {
				let that = this
				// #ifdef APP-PLUS || MP-WEIXIN || MP-ALIPAY
				this._mapContext = uni.createMapContext("map", this);
				// #endif

				// #ifdef APP-PLUS || MP-WEIXIN
				// 支付宝小程序会报错，不支持该方法
				this._mapContext.initMarkerCluster({
					enableDefaultStyle: false,
					zoomOnClick: true,
					gridSize: 60
				});
				
				this._mapContext.on("markerClusterCreate", (e) => {
					const markers = e.clusters.map(cluster => {
						const {
							center,
							clusterId,
							markerIds
						} = cluster


						var SystemInfoSync = uni.getSystemInfoSync().platform


						if (markerIds.length > 99) {
							return {
								...center,
								clusterId,
								width: 40,
								height: 47,
								iconPath: this.configClusterIcon.THREE_AGGREGATION_ICON ||
									'https://oos-cn.ctyunapi.cn/front-end/static/static/marker2.png',
								joinCluster: true,
								label: {
									content: markerIds.length + '',
									width: 46,
									height: 46,
									color: '#73A843',
									fontSize: 12,
									textAlign: 'center',
									anchorX: -18,
									anchorY: -50
								}
							};
						} else {
							return {
								...center,
								clusterId,
								width: 36,
								height: 41,
								iconPath: this.configClusterIcon.TWO_AGGREGATION_ICON ||
									'https://oos-cn.ctyunapi.cn/front-end/static/static/marker1.png',
								joinCluster: true,
								label: {
									content: markerIds.length + '',
									width: 40,
									height: 40,
									color: '#ffffff',
									fontSize: 13,
									textAlign: 'center',
									anchorX: SystemInfoSync == 'android' ? -20 : 0,
									anchorY: -44
								}
							};
						}
					})


					this._mapContext.addMarkers({
						markers,
						clear: false
					})
				});
				// #endif

				// #ifdef H5
				var script = document.createElement("script");
				script.type = "text/javascript";
				// script.async = true;
				let key = app.globalData.mapH5key
				console.log(key, '地图key', app.globalData.mapH5key1)
				window._AMapSecurityConfig = {
					securityJsCode: app.globalData.mapH5key1,
				}
				script.src = `https://webapi.amap.com/maps?v=2.0&key=${key}&plugin=AMap.MarkerCluster`;
				document.head.appendChild(script);
				script.onload = function() {
					let latitude = uni.getStorageSync("latitude")
					let longitude = uni.getStorageSync("longitude")
					console.log(latitude, longitude, 'sfsdafa')
					that._mapContext = new AMap.Map("map", {
						zoom: 14,
						center: [longitude, latitude], //中心点坐标
					});
				}
				// #endif
			}
		}
	};
</script>
<style lang="less" scoped>
	@import url('./index.less');
	@import url('./index2.less');


	// 新加优惠展示样式
	@import url('./site-discount.less');
</style>